package com.xxxx.seckill.config;//package com.xxxx.seckill.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Mq配置类
 *
 * @author A
 */
@Configuration
public class RabbitMQTopicConfig {

    private static final String QUEUE = "seckillQueue";
    private static final String EXCHANGE = "seckillExchange";
    private static final String EXCHANGE1 = "payExchange";
    private static final String EXCHANGE2 = "cannelExchange";
    private static final String QUEUE02 = "payQueue";
    private static final String QUEUE03 = "cannelQueue";

    @Bean
    public Queue queue() {
        return new Queue(QUEUE);
    }

    @Bean
    public Queue queue1() {
        return new Queue(QUEUE02);
    }

    @Bean
    public Queue queue2() {
        return new Queue(QUEUE03);
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(EXCHANGE);
    }

    @Bean
    public TopicExchange topicExchange1() {
        return new TopicExchange(EXCHANGE1);
    }

    @Bean
    public TopicExchange topicExchange2() {
        return new TopicExchange(EXCHANGE2);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(topicExchange()).with("seckill.#");
    }

    @Bean
    public Binding binding1() {
        return BindingBuilder.bind(queue1()).to(topicExchange1()).with("pay.#");
    }

    @Bean
    public Binding binging2() {
        return BindingBuilder.bind(queue2()).to(topicExchange2()).with("cancel.#");
    }

}
